<?php
namespace app\common\service\ability\service;
use app\common\service\ability\interfaces\DictionaryAbility;
use app\common\exception\TokenException;
use app\common\exception\LogicException;
use app\common\model\Dictionary;
use think\db\exception\DataNotFoundException;
//字典值能力类
class DictionaryAbilityService implements DictionaryAbility{
    public function __construct(Dictionary $Dictionary)
    {
        $this->models = $Dictionary;
    }
    //获取字典值列表带分页
    public function getListPage($where){
        $page = getPageData();
        $orderStr = getOrderString();
        return $this->models->where($where)->limit($page['start'], $page['limit'])->order($orderStr.'dictionary_id desc')->select();
    }
    //获取条数
    public function getCount($where){
        return $this->models->where($where)->count();
    }
    //保存字典值添加
    public function saveAdd($addData){
        return $this->models->create($addData);
    }
    //获取字典值信息
    public function getLine($where){
        return $this->models->where($where)->find();
    }
    public function saveEdit($editData){
        $where[]=['dictionary_id','=',$editData['dictionary_id']];
        return  $this->getLine($where)->save($editData);
    }
    public function saveDel($delData){
        $where[]=['dictionary_id','=',$delData['dictionary_id']];
        return  $this->getLine($where)->delete();
    }
}